 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

//hhhhhhhhhhhh
//ppppppppppppppp
    class GetNumbers
    {
        //Program 01
        public void GetNumber()
        {
            List<int> listNum = new List<int>();
            while (true)
            {
                Console.Clear();
                Console.Write("Input the number : ");
                string numStr = Console.ReadLine();

                if (numStr == "exit")
                {
                    TextWriter tw = new StreamWriter(@"C:\data.txt");
                    for (int i = 0; i < listNum.Count(); i++)
                    {
                        tw.WriteLine(listNum.ElementAt(i));
                    }
                    tw.Close();
                    break;
                }
                else
                {
                    try
                    {
                        int num = Convert.ToInt32(numStr);
                        listNum.Add(num);
                    }
                    catch
                    {
                        Console.Clear();
                        Console.WriteLine("Your input the incorrect number.");
                        Console.Write("Input the number again : ");
                        numStr = Console.ReadLine();
                    }

                }

            }
        }
    }
}
